﻿using _05.状态模式.Enums;
using _05.状态模式.Factories;
using _05.状态模式.States;

namespace _05.状态模式.Entities
{
    /// <summary>
    /// 项目实体
    /// </summary>
    public class Project
    {
        #region 01.构造器
        /// <summary>
        /// 无参构造器
        /// </summary>
        protected Project() { }

        /// <summary>
        /// 创建项目构造器
        /// </summary>
        /// <param name="projectName">项目名称</param>
        public Project(string projectName)
        {
            this.ProjectName = projectName;
            this.ProjectStatus = ProjectStatus.Discussing;
        }
        #endregion

        #region 02.属性

        #region 项目Id —— int Id
        /// <summary>
        /// 项目Id
        /// </summary>
        public int Id { get; set; }
        #endregion

        #region 项目名称 —— string ProjectName
        /// <summary>
        /// 项目名称
        /// </summary>
        public string ProjectName { get; private set; }
        #endregion

        #region 项目状态 —— ProjectState ProjectState
        /// <summary>
        /// 项目状态
        /// </summary>
        internal ProjectState ProjectState
        {
            get
            {
                return ProjectStateFactory.GetProjectState(this.ProjectStatus);
            }
        }
        #endregion

        #region 项目状态枚举 —— ProjectStatus ProjectStatus
        /// <summary>
        /// 项目状态枚举
        /// </summary>
        public ProjectStatus ProjectStatus { get; internal set; }
        #endregion

        #endregion

        #region 03.方法

        #region 签约 —— void Sign()
        /// <summary>
        /// 签约
        /// </summary>
        public void Sign()
        {
            this.ProjectState.Sign(this);
        }
        #endregion

        #region 施工 —— void Construct()
        /// <summary>
        /// 施工
        /// </summary>
        public void Construct()
        {
            this.ProjectState.Construct(this);
        }
        #endregion

        #region 完工 —— void Finish()
        /// <summary>
        /// 完工
        /// </summary>
        public void Finish()
        {
            this.ProjectState.Finish(this);
        }
        #endregion

        #region 结算 —— void Settle()
        /// <summary>
        /// 结算
        /// </summary>
        public void Settle()
        {
            this.ProjectState.Settle(this);
        }
        #endregion

        #endregion
    }
}
